<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>通过方法的实现</title>
		<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
	</head>
	<body>
		<div id="box">
			姓名: <input type="text" v-model="name"> <br>
			公司名: <input type="text" v-model="company"> <br>
			<!-- 页面去调用方法 -->
			<h1>{{ email() }}</h1>
			<h1>{{ email() }}</h1>
			<h1>{{ email() }}</h1>
		</div>
		<script type="text/javascript">
			const vm = new Vue({
				el:'#box',
				data:{
					name:'',
					company:''
				},
				methods:{
					email(){
						console.log("我被执行了");
						if(this.name == "张三"){
							return "zhangsan@" + this.company + ".com"
						}else{
							return this.name + "@" + this.company + ".com"
						}
					}
				}
			})
		</script>
	</body>
</html>
